use sea_orm::{DerivePartialModel, FromQueryResult};
use serde::Serialize;
mod cms;
mod manager;
pub use cms::*;
pub use manager::*;
pub(crate) type Result<T> = std::result::Result<T, sea_orm::DbErr>;
use crate::entity::prelude::*;

#[derive(Debug, DerivePartialModel, FromQueryResult, Serialize)]
#[sea_orm(entity = "CmsArticle")]
pub struct ArticleListVo {
    pub id: i32,
    /// 文章标题
    pub title: String,
    /// 作者
    pub author: String,
    /// 封面图
    pub image: String,
    /// 关键词
    pub keywords: String,
    /// 简介
    pub description: String,
    /// 是否允许评论
    pub allow_comments: bool,
    /// 状态
    /// - 0 待发布
    /// - 1 审核中
    /// - 2 已发布
    /// - 3 被驳回
    /// - `>=64` 回收站
    pub status: u8,
    /// 阅读数量
    pub read_number: u32,
    pub publish_at: chrono::NaiveDateTime,
}

#[derive(Debug, DerivePartialModel, FromQueryResult, Serialize)]
#[sea_orm(entity = "CmsArticle")]
pub struct ArticleDetailVo {
    pub id: i32,
    /// 所属专题
    pub topic_id: i32,
    /// 文章标题
    pub title: String,
    /// 作者
    pub author: String,
    /// 转载来源网址
    pub fromurl: String,
    /// 封面图
    pub image: String,
    /// 关键词
    pub keywords: String,
    /// 简介
    pub description: String,
    /// 是否允许评论
    pub allow_comments: bool,
    /// 状态
    /// - 0 待发布
    /// - 1 审核中
    /// - 2 已发布
    /// - 3 被驳回
    /// - `>=64` 回收站
    pub status: u8,
    /// 发布人id
    pub user_id: i32,
    /// 阅读数量
    pub read_number: u32,
    /// 内容
    pub content: String,
    pub is_markdown: bool,
    pub publish_at: chrono::NaiveDateTime,
}

#[derive(Debug, Serialize)]
pub struct CategoryVo {
    pub id: i32,
    pub p_id: i32,
    pub sort: i32,
    pub name: String,
    pub alias: String,
    pub icon: String,
    pub children: Vec<CategoryVo>,
}

#[derive(Debug, DerivePartialModel, FromQueryResult, Serialize)]
#[sea_orm(entity = "CmsCategory")]
pub struct CategoryDetailVo {
    pub id: i32,
    pub p_id: i32,
    pub name: String,
    pub alias: String,
    pub icon: String,
    pub description: String,
    pub status: i8,
}
